#!/bin/bash
cd ~/app-root/data/temp/Nexus4
url=$(curl -s https://github.com/opengapps/arm64/releases/ | grep -o 'opengapps/arm64/releases/download/[0-9]\{8\}/open_gapps-arm64-7.1-pico-[0-9]\{8\}\.zip' |sed '2,$d')
if ! grep -q "$url" gappsurl; then
echo $url > gappsurl
wget --no-check-certificate https://github.com/$(cat gappsurl) --output-document=gapps.zip
zip gapps.zip -d GApps\/* Optional\/* Core/configupdater* Core/gmssetup* Core/googlefeedback* Core/googleonetimeinitializer* Core/googlepartnersetup* Core/setupwizardtablet* Core/androidplatform*
unzip -o gapps.zip installer.sh
sed -i '/Remove ALL Existing GApps files/a\rm -f /system/recovery\*\ncp -rf /sdcard/SpeedSoftware/Extracted/7.1/\* /system/\nsed -i \"/gChannelBondingMode24GHz/s#0#1#\" /system/etc/wifi/*_cfg.ini\nsed -i -e \"/^NTP_SERVER/d\" -e \"/^SUPL_HOST/d\" -e \"/^SUPL_PORT/d\" -e \"/^#Asia$/r /sdcard/SpeedSoftware/Extracted/gps.txt\" /system/etc/gps.conf' installer.sh
zip -u gapps.zip installer.sh
rm -f installer.sh ~/app-root/repo/Nexus4/open_gapps-arm64*.zip
mv -f gapps.zip ~/app-root/repo/Nexus4/$(grep -o "open_gapps-arm64.*zip" gappsurl)
~/app-root/data/github-sh/Nexus4/openload_uploader.sh upload "$(ls /var/lib/openshift/53eafa98e0b8cdd9f1000005/app-root/repo/Nexus4/open_gapps-arm64*.zip)" "OnePlus3T"
fi
